<template>
	<view class="webview">
		<button @click="btn1">小程序授权（差最后一步接口）</button>
		<button @click="btn2">公众号授权（差最后绑定账号接口）</button>
		<button @click="btn3">小程序定位(考勤打卡)</button>
		<button @click="btn4">公众号定位(公众号自带的经纬度>腾讯地图位置信息)</button>
		<button @click="btn5">微信支付（未配置）</button>
		<button @click="btn51">掌银H5支付（）</button>
		<button @click="btn6">预览和下载pdf</button>
		
		<button @click="btn7">小程序扫一扫</button>
		<!-- <button @click="btn8">公众号扫一扫</button> -->
		<button @click="btn9">腾讯天气</button>
		<button @click="btn10">webview</button>
		<!-- <uni-link href="https://static-b355b199-f26f-4bea-b13c-1b2c8fff663f.bspapp.com/testpdf.pdf"
		 text="浏览器打开pdf/"></uni-link> -->
		
	</view>
</template>

<script>
	import store from '@/store'
	export default {
		data() {
			return {
				// url: 'https://hengrun.smallsesame.site/webview.html?t='+new Date().getTime()
				// url:'https://render.alipay.com/p/w/tinyapp-demo-h5/index.html'
				//wx.miniProgram.navigateBack({delta: 1})
			} 
		},
		onLoad(op) {
			// console.log('url', this.url)
			// this.showlog()
			// this.showlog2(33);
			// this.handlePostMessage(1)
			// this.openWebview(op);
		},
		methods: {
			btn1(){
				uni.redirectTo({
					url: '/pages/index/authorize'
				})
			},
			btn2(){
				uni.redirectTo({
					url: '/pages/index/authorizeMp'
				})
			},
			btn3(){
				uni.redirectTo({
					url: '/pages/index/getLocation'
				})
			},
			btn4(){
				uni.redirectTo({
					url: '/pages/index/getLocationMp'
				})
			},
			btn5(){
				// uni.redirectTo({
				// 	url: '/pages/index/getLocationMp'
				// })
				uni.requestPayment({
				    provider: 'wxpay',
					timeStamp: String(Date.now()),
					nonceStr: 'A1B2C3D4E5',
					package: 'prepay_id=wx20180101abcdefg',
					signType: 'MD5',
					paySign: '',
					success: function (res) {
						console.log('success:' + JSON.stringify(res));
					},
					fail: function (err) {
						console.log('fail:' + JSON.stringify(err));
					}
				});
			},
			btn51(){
				uni.navigateTo({
					url:'/pages/webview/pay_h5?type=jkbp',
					
				})
			},
			btn6(){
				// uni.openDocument({
				//       filePath: 'https://static-b355b199-f26f-4bea-b13c-1b2c8fff663f.bspapp.com/testpdf.pdf',
				//       showMenu: true,
				//       success: function (res) {
				//         console.log('打开文档成功2');
				//       }
				//     });
				uni.downloadFile({
					url:'https://smartpark.fintechabchina.com/c9228d63-72c9-4aac-b93f-20e4a5dada82',
					// url: 'https://static-b355b199-f26f-4bea-b13c-1b2c8fff663f.bspapp.com/testpdf.pdf', //仅为示例，并非真实的资源
					success: (res) => {
						console.log('下载pdf',res)
						if (res.statusCode === 200) {
							// console.log('下载成功');
							
							var filePath = res.tempFilePath;
							// uni.getFileSystemManager().saveFile({
							//   tempFilePath: tempFilePaths,
							//   success: function (res2) {
							// 	  console.log('保存pdf',res2);
							// 	var savedFilePath = res2.savedFilePath;
							//   }
							// });
							
							uni.openDocument({
							      filePath: filePath,
							      showMenu: true,
							      success: function (res) {
							        console.log('打开文档成功');
							      }
							    });
						}
					}
				});
			},
			btn7(){
				uni.scanCode({
					success: function (res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
			},
			btn8(){
				uni.scanCode({
					success: function (res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
			},
			btn9(){
				uni.navigateTo({
					url:'/pages/samplepage/weather'
				})
			},
			btn10(){
				uni.navigateTo({
					url:'/pages/webview/webview'
				})
			}
		}
	}
</script>

<style lang="scss">
	.webview {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #F7F8FA ;
		box-sizing: border-box;
		padding: 0 16rpx;
		overflow: auto;
		button {
			width: 96%;
			height: auto;
			margin:2%;
			text-align: center;
		}
	}
</style>
